package cn.sharp.bbs.dao.user;

import cn.sharp.bbs.entity.BO.UserBreif;
import cn.sharp.bbs.entity.DO.Group;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserFollowDao {
    List<Group> getFollowGroups(Long uid);

    List<UserBreif> listFollowAll(Long u_id);
    List<UserBreif> listUserInGroup(Long u_id, Long group);

    List<UserBreif> getRecentFollows(Long uid);

    @Select("select fuser_id from t_follow_user where user_id=#{source} and user_followed=#{target}")
    Long getFollowId(Long source, Long target);

    @Select("select count(*) from t_follow_group where fuser_id=#{followId} and group_id=#{group}")
    int countFollowInGroup(Long followId, Long group);

    @Insert("insert into t_follow_group (group_id, fuser_id) VALUE (#{group}, #{followId})")
    void addFollowToGroup(Long followId, Long group);

    List<Group> getFollowInGroup(Long source, Long target);

    @Delete("delete from t_group where group_id=#{group}")
    void delGroup(Long group);
}
